<?php
class Con_data extends Acan{
	public $defaultAct='list';
	public $Conread = '数据';
	public $Actread = array('qqkh'=>'快号QQ群号码','qqkh_get'=>'快号QQ群号码获取');
	function __construct($ainfo=null){
		$this->atitle = $this->Actread[$this->Aact];
		parent::__construct($ainfo=null);
	}
	function kh_mail($tomail,$toname,$title,$body,$attachment=null,$frommail=null,$fromname=null){
		$op = Afunc_option();
		define('Acan_email_user',$op->get('Acan_email_user'));				//用户名
		define('Acan_email_pass',$op->get('Acan_email_pass'));				//密码
		define('Acan_email_smtp',$op->get('Acan_email_smtp'));				//smtp 地址
		define('Acan_email_port',$op->get('Acan_email_port'));				//smtp 端口
		define('Acan_email_frommail',$op->get('Acan_email_frommail'));		//来源email地址
		define('Acan_email_fromname',$op->get('Acan_email_fromname'));		//来源名称
		define('Acan_email_replymail',$op->get('Acan_email_replymail'));	//回复email地址
		define('Acan_email_replyname',$op->get('Acan_email_replyname'));	//回复名称
		define('Acan_email_pop',$op->get('Acan_email_pop'));				//pop 地址
		define('Acan_email_pport',$op->get('Acan_email_pport'));			//pop 端口
		$data = array(
			'title'=>$title,
			'body'=>$body,
			'tomail'=>$tomail,
			'toname'=>$toname,
			'frommail'=>$frommail,
			'fromname'=>$fromname,
			'replymail'=>$replymail,
			'replyname'=>$replyname,
			'attachment'=>$attachment
			);
		return Afun_mail_one($data);
	}
	//发布数据提交
	function Act_qqkh_get(){
		$model = Afun_db()->model('acan_data_qqkh');
		$con->select = 'qq,name';
		$con->where = 'status=0';
		$con->limit = 10;
		$rs = $model->ofindAll($con);
		print_r($rs);
	}
	function Act_qqkh(){
		if($_POST){
			$model = Afun_db()->model('acan_data_qqkh');
			if(in_array(Afun_get_ip(),array('112.124.9.158','127.0.0.1'))){
				header('Content-type: text/html; charset=UTF-8');
				header('Access-Control-Allow-Origin: *');
			}
			$arr = explode("\n",$_POST['data']);
			$rsi=0;
			if(is_array($arr)){
				foreach ($arr as $k => $v) {
					$save = array();
					$vrr = explode("|",$v);
					if(strlen($vrr[0])>2){
						$save['qq']=trim($vrr[0]);
						$save['name']=trim($vrr[1]);
						$old = $model->find(array('qq'=>$save['qq']));
						if(!$old){
							$save['group']=json_encode(array($_POST['group']=>1));
							$ii+=$model->save($save,1);
						}else{
							$group=Afun_obj_arr(json_decode($old['group']));
							if(!$group[$_POST['group']]){
								$group[$_POST['group']]=1;
								$save['group']=json_encode($group);
							}
							$ui+=$model->update($save,array('qq'=>$save['qq']));
						}
					}
				}
			}
			$status = 1;
			$msg = '插入'.$ii.',更新'.$ui;
			if($_GET['ajax']==1){
				Afun_json(array('status'=>$status,'msg'=>$msg,'rs'=>$rsi));
			}else{
				echo $msg;
			}
		}
		include $this->Atpl();
	}
}

?>